/*
 * RadioButtonMenuItemDelegate.h  0.4.0 / Dec 05, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef RADIOBUTTONMENUITEMDELEGATE_H
#define RADIOBUTTONMENUITEMDELEGATE_H

#include "Cute4jSwing.h"

#include "ActionComponentDelegate.h"

// RadioButtonMenuItemDelegate Class. ------------------------------------------

/*!
 * \brief RadioButtonMenuItem Delegate.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT RadioButtonMenuItemDelegate :
                                                  public ActionComponentDelegate
{
  Q_OBJECT
protected:
  RadioButtonMenuItemDelegate(JNIEnv *env, jobject obj);
public slots: // native calls
  void setText(JNIEnv *env, jstring text);
  void setShortcut(JNIEnv *env, jstring shortcut);
  void setIcon(JNIEnv *env, jobject iconSet);
  void setSelected(JNIEnv *env, jboolean selected);
public: // native calls
  static void initialize(JNIEnv *env, jclass cls);
  static jlong newInstance(JNIEnv *env, jobject obj);
public: // native callbacks
  void selectedChanged(jint modifiers, jboolean selected);
protected slots:
  void toggledSlot(bool checked);
protected:
  inline QRadioButton *radioButton() const;
protected:
  virtual QWidget *createQWidget();
  virtual QAction *createQAction();
  virtual void deleteQWidget(QWidget *widget);
  virtual void deleteQAction(QAction *action);
  virtual QWidget *convertToQWidget(QAction *action);
  virtual QAction *convertToQAction(QWidget *widget);
protected:
  static QActionGroup *actionGroup();
private:
  QShortcut *m_shortcut;
  QActionGroup *m_actionGroup;
private:
  static jmethodID sm_selectedChangedMID;
};

// RadioButtonMenuItemDelegate :: Protected Inline Member Function. ------------

/*!
 * \brief Returns radio button member.
 *
 * \return radio button member
 */
inline QRadioButton *RadioButtonMenuItemDelegate::radioButton() const
{
  return static_cast<QRadioButton *>(widget());
}

// Macro Definition. -----------------------------------------------------------

#define RADIO_BUTTON_MENU_ITEM_DELEGATE \
    (reinterpret_cast<RadioButtonMenuItemDelegate *>(delegate))

#endif // RADIOBUTTONMENUITEMDELEGATE_H
